package
{
	import com.feng.ControllerCenter;
	import com.feng.FengData;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;

	/**
	 *
	 * @author 风之守望者
	 */
	public class Feng extends Sprite
	{
		private var version:String = "4.15 13:51";

		[Embed(source = "../embeds/feng.png")]
		private var avatar:Class;

		/**
		 * 控制中心
		 */
		private var controllerCenter:ControllerCenter;

		public function Feng()
		{
			FengData.showData = false;
			FengData.showInfo = false;
			
			controllerCenter = new ControllerCenter();
		}

		public function onAttack(state:Array, myId:int):int
		{
			return controllerCenter.onAttack(state, myId);
		}

		public function onUpgrade(state:Array, myId:int, isKillUpgrade:Boolean):int
		{
			return controllerCenter.onUpgrade(state, myId, isKillUpgrade)
		}

		public function onTurn(state:Array, myId:int):void
		{
			controllerCenter.onTurn(state, myId);
		}

		public function onAnyoneAttack(state:Array, myId:int, attacker:int, target:int):void
		{
			controllerCenter.onAnyoneAttack(state, myId, attacker, target);
		}

		public function onAnyoneUpgrade(state:Array, myId:int, upgrader:int, upgradeType:int):void
		{
			controllerCenter.onAnyoneUpgrade(state, myId, upgrader, upgradeType);
		}

		public function onBattleStart(myId:int):void
		{
			controllerCenter.onBattleStart(myId);
		}

		public function onBattleFinish(totalBattles:int, myVectories:int):void
		{
			controllerCenter.onBattleFinish(totalBattles, myVectories)
		}

		public function onGameSet(gameMode:int, players:int):void
		{
//			if (gameMode > 10)
//			{
//				FengData.showData = false;
//				FengData.showInfo = false;
//			}

			controllerCenter.onGameSet(gameMode, players);
		}

		public function onPlayerNumChanged(state:Object, myId:int, livingMD5:Array, myMD5:String):void
		{
			controllerCenter.onPlayerNumChanged(state, myId, livingMD5, myMD5);
		}

		//在游戏中显示角色的名字。请控制在8个字以内，太长显示不下影响效果。默认值是文件名。
		public function getName():String
		{
			//劳资的大名
			return "风-" + version;
		}

		//GUI中，游戏中小人的颜色。默认值0xeeeeee。只取后24位，Alpha无效。
		public function getColor():uint
		{
			return 0x000088;
		}

		//可以使用echo(str)方法向游戏中的控制台输出调试用的log。在多场竞技中也有效。
		public function setEchoFunction(echo:Function):void
		{
			FengData.printInfo = echo;
		}

		//你的标识
		//会显示在单场模式上的文化衫上面，尺寸将被缩放到32x16
		//会显示在竞技模式的胜率条前面，尺寸将被缩放到64x32
		//默认不显示
		public function getIcon():Bitmap
		{
			//下面的头像是个黑方块，太难看了，谁给改改吧！
			//记着要64x32的！
			return new avatar();
		}

	}
}
